from rest_framework import serializers

from environments.models import Environment
from records.models import Record, Report
from test_plans.models import TestPlan


class RecordSerializer(serializers.ModelSerializer):
    plan = serializers.PrimaryKeyRelatedField(queryset=TestPlan.objects.all().filter(is_deleted=False))
    test_env = serializers.PrimaryKeyRelatedField(queryset=Environment.objects.all().filter(is_deleted=False))
    env_name = serializers.StringRelatedField(read_only=True, source='test_env')
    plan_name = serializers.StringRelatedField(read_only=True, source='plan')

    class Meta:
        model = Record
        fields = '__all__'


class ReportSerializer(serializers.ModelSerializer):
    class Meta:
        model = Report
        fields = '__all__'
